<?php

namespace App\Models;

use App\Utils\Arr;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Model as BaseModel;

abstract class Model extends BaseModel
{
    /**
     * 为 array / JSON 序列化准备日期格式
     */
    protected function serializeDate(DateTimeInterface $date): string
    {
        return $date->format('Y-m-d H:i:s');
    }

    /**
     * 格式化key   user_id ~~ userId
     * @return array
     */
    public function toArray(): array
    {
        return Arr::key0Studly(parent::toArray());
    }
}
